<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>btn1</button>
<button>btn2</button>
<button>btn3</button>
<button>btn4</button>
<button>btn5</button>
<script>
    var btns = document.getElementsByTagName('button');
    for (let i =0; i<btns.length;i++){
        btns[i].addEventListener('click',function () {
            alert(i)
        })
    }
</script>
</body>
</html>
